<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="java.sql.*,java.util.*,java.text.*,java.text.SimpleDateFormat" %>
<%@ page import="javax.servlet.*" %>
<%@page import="connection.DBConnection"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Master details</title>
<script type="text/javascript" src="JS/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('#sbutton').click(function(e) {
	        e.preventDefault();
	        var a0=$("#pan").val();
	    		 var a1 = $("#org").val();
	    		    var a2 = $("#mvat").val();
	    		    var a3 = $("#add").val();
	    		    var a4 = $("#city").val();
	    		    var a5 = $("#dist").val();
	    		    var a6 = $("#state").val();
	    		    var a7 = $("#pin").val();
	    		    var a8 = $("#person").val();
	    		    var a9=$("#des").val();
	    		    var a10=$("#email").val();
	    		    var a11=$("#mobile").val();
	    		    
var value ='pan1='+a0+'&or='+a1+'&mv='+a2+'&ad='+a3+'&ct='+a4+'&ds='+a5+'&st='+a6+'&pn='+a7+'&pr='+a8+'&des='+a9+'&mail='+a10+'&mb='+a11;

var c1,c2,c3,c4,c41,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15;

	var namevalid=/^[a-zA-Z ]+$/;

    c1= document.f1.org.value;

    
    if(c1.search(namevalid)==-1)
    {
        alert("Please Enter valid name");
        document.f1.org.value="";
        document.f1.org.focus();
        
         return false;
	 }
     
    c2= document.f1.mvat.value;
    
    
    if(!c2.match(/^\d+$/))
  	 {
   	 alert("Please Enter MVAT no. in digits only");
   	document.f1.mvat.value="";
    document.f1.mvat.focus();
        return false;
  	 }

    
   
    
      /*  var regExp1 = /^(\d{1,2})\/(\d{1,2})\/(\d{2})$/;
        var regExp2 = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
        var result1 = document.f1.dob.value.match(regExp1);
        var result2 = document.f1.dob.value.match(regExp2);
        
        if (result1 == null && result2 == null)
        {
            alert("Enter a valid date.");
            document.f1.dob.value = "";
            document.f1.dob.focus();
            return false;
        }*/
    
     
     
    
    
     
      c10= document.f1.city.value;
      if(c10.length == 0)
      {
          alert("Please Enter City");
          
          document.f1.city.focus();
          return false;
      }
      if(c10.search(namevalid)==-1)
      {
          alert("Please Enter valid  City name");
          document.f1.city.value="";
          document.f1.city.focus();
          
	         return false;
  	 }
      c11= document.f1.dist.value;
      if(c11.length == 0)
      {
          alert("Please Enter District");
         
          document.f1.dist.focus();
          return false;
      }
       if(c11.search(namevalid)==-1)
      {
          alert("Please Enter valid District name");
          document.f1.dist.value="";
          document.f1.dist.focus();
          
	         return false;
  	 }
       
       c7= document.f1.state.value;

       
      	
       if(c7.search(namevalid)==-1)
      {
          alert("Please Enter valid State");
          document.f1.state.value="";
          document.f1.state.focus();
          
	         return false;
  	 }


      c12= document.f1.pin.value;
      if(c12.length==0)
      {
      	alert("Enter Pincode");
      	
        document.f1.pin.focus();
          return false;
    	 }
      
       if(!c12.match(/^\d+$/))
    	 {
     	 alert("Please Enter Pincode in Numerics only");
     	document.f1.pin.value="";
        document.f1.pin.focus();
          return false;
    	 }
       if(c12.indexOf(" ")!=-1)
 	 {
    		alert("Invalid Pincode No.");
    		document.f1.pin.value="";
            document.f1.pin.focus();
   		return false;
 	 }
 	  if(c12.length>6)
  	 {
      	alert("Pincode should be 6 digit");
      	document.f1.pin.value="";
        document.f1.pin.focus();
    		return false;
  	 }

      c13= document.f1.person.value;

     
      if(c13.search(namevalid)==-1)
      {
          alert("Please Enter valid name");
          document.f1.person.value="";
          document.f1.person.focus();
          
	         return false;
  	 }
      

$.ajax({
	 type:"post",  //post method
	 url: "EditRegisterServlet3", //ajaxformexample url
	 data: value, //
cache: false,
success: function(data) {
// $("#country").val('');
  $("#message").html(data).slideDown('slow');

	// $('.success').fadeIn(200).show();
	  // $('.error').fadeOut(200).hide();  		    }
	
}
});
	
return false;
});
}); 
</script>
<script language="javascript" type="text/javascript">

function check()
{
	
         
          return true;
}


    </script>

</head>
<body>


<h2 align="center"> Master Details</h2>
<form name="f1" action="EditRegisterServlet3" method=post>

<%String selectedpan=session.getAttribute("user2").toString();
DBConnection dbc2=new DBConnection();
Connection con5=dbc2.getNewConnection();
Statement st5 = null;
ResultSet rs5 = null;
//out.println(selectedpan);
String a1="",a3="",a4="",a5="",a6="",a8="",a9="", a2="",a7="",a10="";
long mob=0000000000;
try{
 st5 = con5.createStatement();
 String query="select email,mobile from register where panno='"+selectedpan+"'";
 rs5 = st5.executeQuery(query);
 while(rs5.next()){ 
	 a10=rs5.getString(1);
	 mob=rs5.getLong(2);
 }
String queryString2 = "SELECT  org_name,mvat,address,city,dist,state,pin,autho_person,designation from register2 where panno='"+selectedpan+"' ";
rs5 = st5.executeQuery(queryString2);
while(rs5.next()){ 
		
	a1=rs5.getString(1); //bankname	        
	   a2=rs5.getString(2);
	    a3=rs5.getString(3);
		 a4=rs5.getString(4); //amount11
	  a5=rs5.getString(5);
	  a6=rs5.getString(6);
	  a7=rs5.getString(7);
	  a8=rs5.getString(8);
	  a9=rs5.getString(9);
	  
}

con5.close();

}
catch(Exception e)
{
	
}

%>
<input type="hidden" name="pan" id="pan" value="<%=selectedpan%>"/>
<table cellspacing=6 align="center">
<tr>
<td>Name of the Organisation</td>
<td><input type="text" name="org" id="org" value="<%=a1%>"/></td>
</tr>
<tr>
<td>MVAT Number</td>
<td><input type="text" name="mvat" id="mvat" value="<%=a2%>"/></td>
</tr>
<tr>
<td>Address</td>
<td><input type="text" name="add" id="add" value="<%=a3%>"/></td>
</tr>

<tr>
<td>City</td>
<td><input type="text" name="city" id="city" value="<%=a4%>"/></td>
</tr>
<tr>
<td>District</td>
<td><input type="text" name="dist" id="dist" value="<%=a5%>"/></td>
</tr>
<tr>
<td>State</td>
<td><input type="text" name="state" id="state" value="<%=a6%>"/></td>
</tr>

<tr>
<td>Pin Code</td>
<td><input type="text" name="pin" id="pin" value="<%=a7%>"/></td>
</tr>
<tr>
<td>Name of the Authorised Person</td>
<td><input type="text" name="person" id="person" value="<%=a8%>"/></td>
</tr>
<tr>
<td>Designation</td>
<td><select name=des id=des>
<option><%=a9 %></option>
<option>Proprietor</option>
<option>Partner</option>
<option>Director</option>
<option>Authorised Signatory</option>
</select></td>
</tr>
<tr><td>Email id</td><td><input type="text" name="email" id="email" value="<%=a10%>"/></td></tr>
<tr><td>Mobile no.</td><td><input type="text" name="mobile" id="mobile" value="<%=mob%>"/></td></tr>
<tr><td></td>
<td><input type="Button" name="sbutton" id="sbutton" value="Submit"/></td>

</tr>
</table>
</form><br><br>
<center><a href="HomePage.jsp">Back to Home Page</a></center>

<font face="verdana" size="2"><div id="message"></div></font>

</body>
</html>